/**
 * 
 */
package by.jtraining.london.model;

/**
 * @author Irina Pakhomova
 *
 */
import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.Table;

import javax.persistence.InheritanceType;
import com.google.common.base.Objects;

@Entity
@Table(name = "USER")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "ID", discriminatorType = DiscriminatorType.INTEGER)
public class User implements Serializable {
	private static final long serialVersionUID = 4522787481168519L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	private String login;
	@Column(name="password_hash")
	private String passwordHash;
	@Column(name="first_name")
	private String firstName;
	@Column(name="last_name")
	private String lastName;
	@Column(name="is_active")
	private Boolean isActive;

	public User() {
	}

	public User(String firstName, String lastName, String email,
			String password, Boolean isActive) {
		this.firstName = firstName;
		this.lastName = lastName;
		this.login = email;
		this.passwordHash = password;
		this.isActive = isActive;
	}

	public String getFullName() {
		return firstName+" "+lastName;
	}
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPasswordHash() {
		return passwordHash;
	}

	public void setPasswordHash(String passwordHash) {
		this.passwordHash = passwordHash;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Boolean getIsActive() {
		return isActive;
	}

	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		User that = (User) obj;
		return Objects.equal(getLogin(), that.getLogin())
				&& Objects.equal(getPasswordHash(), that.getPasswordHash());
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(getLogin(), getPasswordHash());
	}

}
